/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 table.h

	$Header: /resource_editor/table.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined(TABLE_H_INCLUDED)
#define TABLE_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <assert.h>
#include "string_vector.h"

class t_table_row : public t_string_vector
{
public:
	std::string operator[]( int arg ) const;
};

inline std::string t_table_row::operator []( int arg ) const
{
	assert( arg >= 0 );
	if (arg >= (int)size())
		return std::string();
	return *(begin() + arg);
}

class t_table : public std::vector<t_table_row>
{
public:
	int  get_column_count() const;
	bool read( std::streambuf& buffer );
	bool write( std::streambuf& buffer ) const;
};

inline bool read( std::streambuf& buffer, t_table& table )
{
	return table.read( buffer );
}

template <>
struct t_resource_traits<t_table>
{
	static char const prefix[];
	static char const extension[];
};

#endif // TABLE_H_INCLUDED